package com.accp.ssmoa.mapping;

import java.util.HashMap;
import java.util.List;

/**
 * 分页助手
 * 
 * 
 * 1.封装页面传过来的参数
 * 
 *     封装参数（分页参数、业务参数）
 *     
 *     
 *     封装数据（总行数、当前数据）
 * @author Ackles
 *
 */
public class Pagehelper<T> {
	
	//参数
	
	//分页参数
	private Integer pageNo=1; //当前页码
	
	private Integer pageSize=10; //一页显示多少行
	
	//业务参数    userName   age
	
	private HashMap<String,Object> condition = new  HashMap<String,Object>();
	
	//数据
	
	
	private Integer totalSize;  //总行数
	
	
	private List<T> results;


	public Integer getPageNo() {
		return pageNo;
	}


	public void setPageNo(Integer pageNo) {
		this.pageNo = pageNo;
	}


	public Integer getPageSize() {
		return pageSize;
	}


	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}


	


	public HashMap<String, Object> getCondition() {
		return condition;
	}


	public void setCondition(HashMap<String, Object> condition) {
		this.condition = condition;
	}


	public Integer getTotalSize() {
		return totalSize;
	}


	public void setTotalSize(Integer totalSize) {
		this.totalSize = totalSize;
	}


	public List<T> getResults() {
		return results;
	}


	public void setResults(List<T> results) {
		this.results = results;
	}
	
	
	public Integer getStartRow(){
		return (pageNo-1)*pageSize;
	}
	
	public Integer getMaxPage(){
		int maxPage = totalSize/pageSize;
		
		if(totalSize%pageSize>0){
			maxPage++;
		}
		return maxPage;
	}

}
